using System;
using System.Security.Cryptography;
namespace MicroMsg.Common.Algorithm
{
	public class AES
	{
		private const string TAG = "aes";
		public static byte[] Encrypt(byte[] data, byte[] byte_0)
		{
			if (data != null && byte_0 != null)
			{
				byte[] array = new byte[16];
				int num = (byte_0.Length > 16) ? 16 : byte_0.Length;
				Buffer.BlockCopy(byte_0, 0, array, 0, num);
				byte[] result;
				using (AesManaged aesManaged = new AesManaged())
				{
					KeySizes[] arg_35_0 = aesManaged.get_LegalKeySizes();
					aesManaged.set_KeySize(128);
					aesManaged.set_BlockSize(128);
					aesManaged.set_Key(array);
					aesManaged.set_IV(array);
					ICryptoTransform cryptoTransform = aesManaged.CreateEncryptor();
					result = cryptoTransform.TransformFinalBlock(data, 0, data.Length);
				}
				return result;
			}
			return null;
		}
		public static byte[] Decrypt(byte[] data, byte[] byte_0)
		{
			if (data != null && byte_0 != null)
			{
				byte[] array = new byte[16];
				int num = (byte_0.Length > 16) ? 16 : byte_0.Length;
				Buffer.BlockCopy(byte_0, 0, array, 0, num);
				byte[] result;
				using (AesManaged aesManaged = new AesManaged())
				{
					aesManaged.set_KeySize(128);
					aesManaged.set_BlockSize(128);
					aesManaged.set_Key(array);
					aesManaged.set_IV(array);
					ICryptoTransform cryptoTransform = aesManaged.CreateDecryptor();
					result = cryptoTransform.TransformFinalBlock(data, 0, data.Length);
				}
				return result;
			}
			return null;
		}
	}
}
